package com.todo.strategy.online.application.frontend.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.strategy.online.application.frontend.service.PlatformStrategyAggService;
import com.todo.strategy.online.iface.PlatformStrategyFrontendIface;
import com.todo.strategy.online.iface.request.BoutiquePlatformStrategyParam;
import com.todo.strategy.online.iface.request.PlatformStrategyDetailParam;
import com.todo.strategy.online.iface.request.QueryPlatformStrategyRelationParam;
import com.todo.strategy.online.iface.response.PlatformStrategyDetailVO;
import com.todo.strategy.online.iface.response.PlatformStrategyRelationDetailVO;
import com.todo.strategy.online.iface.response.StrategyBaseVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/5/19 14:31
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/strategy")
@Tag(name = "平台攻略前台接口", description = "平台攻略前台接口")
public class PlatformStrategyFrontendController implements PlatformStrategyFrontendIface {

    @Resource
    private PlatformStrategyAggService platformStrategyAggService;


    @Override
    @Operation(summary = "根据主键Id查询平台策略详情")
    @PostMapping("/queryPlatformStrategyById")
    public BizResponse<PlatformStrategyDetailVO> queryPlatformStrategyById(PlatformStrategyDetailParam param) {
        if (param == null){
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()){
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return platformStrategyAggService.queryPlatformStrategyById(param);
    }

    @Override
    @Operation(summary = "根据城市查询精品平台攻略")
    @PostMapping("/queryBoutiquePlatformStrategyListByCity")
    public BizResponse<List<StrategyBaseVO>> queryBoutiquePlatformStrategyListByCity(BoutiquePlatformStrategyParam param) {
        if (param == null){
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()){
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return platformStrategyAggService.queryBoutiquePlatformStrategyListByCity(param);
    }

    @Override
    @Operation(summary = "根据平台攻略Id查询详情列表")
    @PostMapping("/queryPlatformStrategyRelation")
    public BizResponse<PlatformStrategyRelationDetailVO> queryPlatformStrategyRelation(QueryPlatformStrategyRelationParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return platformStrategyAggService.queryPlatformStrategyRelation(param);
    }

}
